<?php
/* @var $this UserTbController */
/* @var $model UserTb */
/* @var $form CActiveForm */
?>
<!--
<link rel="stylesheet" href="http://salesmartlink.com/js/ui/themes/base/jquery.ui.all.css">
<script src="http://salesmartlink.com/js/jquery-1.9.1.js'"></script>
<script src="http://salesmartlink.com/js/ui/jquery.ui.core.js"></script>
<script src="http://salesmartlink.com/js/ui/jquery.ui.widget.js"></script>
<script src="http://salesmartlink.com/js/ui/jquery.ui.datepicker.js"></script>
<script>
    $(function() {
        $("#datepicker").datepicker({
            changeMonth: true,
            changeYear: true,
        });
        $("#datepicker").datepicker("option", "dateFormat", 'yy-mm-dd');
    });
</script>
-->
<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'user-tb-user-form',
        // Please note: When you enable ajax validation, make sure the corresponding
        // controller action is handling ajax validation correctly.
        // See class documentation of CActiveForm for details on this,
        // you need to use the performAjaxValidation()-method described there.
        'enableAjaxValidation' => false,
    ));
    ?>


    <?php echo $form->errorSummary($model); ?>


    <div class="row">
        <div class="form_left">
            <?php echo $form->labelEx($model, 'username'); ?>
        </div>
        <div class="form_right">
            <?php echo $form->textField($model, 'username', array('size' => 40, 'maxlength' => 50, 'required' => 'required')); ?>

        </div>
        <?php echo $form->error($model, 'username'); ?>
        <div class="clear"></div>
    </div>
    <div class="row">
        <div class="form_left">
            <?php echo $form->labelEx($model, 'email'); ?>
        </div>
        <div class="form_right">
            <?php
            $session = new CHttpSession;
            $session->open();
            // $id = $session['user_salesmart'][3];
            if (!empty($session['user_salesmart'])) {

                echo $form->textField($model, 'email', array('size' => 40, 'maxlength' => 100, 'required' => 'required', 'readOnly' => true));
            } else {
                echo $form->textField($model, 'email', array('size' => 40, 'maxlength' => 100, 'required' => 'required'));
            }
            ?>

        </div>

        <?php echo $form->error($model, 'email'); ?>

        <div class="clear"></div>
    </div>
    <?php
    if (!empty($session['user_salesmart'])) {
        
    } else {
        ?>
        <div class="row">
            <div class="form_left">
                <?php echo $form->labelEx($model, 'pass'); ?>
            </div>
            <div class="form_right">
                <?php echo $form->passwordField($model, 'pass', array('id' => 'pwd', 'size' => 40, 'maxlength' => 50, 'required' => 'required')); ?>

            </div>
            <?php echo $form->error($model, 'pass'); ?>
            <div class="clear"></div>
        </div>
        <div class="form_left">
            Nhập lại mật khẩu *
        </div>

        <div class="form_right">
            <input id="rpwd" name="rpwd" type="password" class="easyui-validatebox" required="required" validType="equals['#pwd']" size="40">
        </div>
        <div class="clear"></div>
    <?php } ?>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'cmnd'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'cmnd'); ?>
        <?php echo $form->error($model, 'cmnd'); ?>
    </div>
    <div class="clear"></div>
    <div class="row">
        <div class="form_left">
            <?php echo $form->labelEx($model, 'phone'); ?>
        </div>
        <div class="form_right">
            <?php echo $form->textField($model, 'phone', array('size' => 40, 'maxlength' => 20, 'required' => 'required')); ?>

        </div>
        <?php echo $form->error($model, 'phone'); ?>
        <div class="clear"></div>
    </div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'birthday'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'birthday', array('class' => 'easyui-datebox', 'data-options' => 'formatter:myformatter,parser:myparser')); ?>
        <?php echo $form->error($model, 'birthday'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'sex'); ?>
    </div>
    <div class="form_right">

        <?php echo $form->dropDownList($model, 'sex', array('0' => 'Nam', '1' => 'Nữ')); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'cityID'); ?>
    </div>
    <div class="form_right">

        <?php
        
        $location = City::model()->findAll();

        $list = CHtml::listData($location, 'cityID', 'cityName');

      
        echo $form->dropDownList($model, 'cityID', $list, array(
            ));
        ?>



      
        
          <?php
          /*
        if (isset($model->uid)) {
            $session = new CHttpSession;
            $session->open();
            //$session['user_salesmart'][3];

            $listsmenu = City::model()->findAll('flag=1');
            $listmenu = CHtml::listData($listsmenu, 'cityID', 'cityName');
            echo $form->dropDownList($model, 'cityID', $listmenu, array('id' => 'cityID'));
        } else {
            echo $form->dropDownList($model, 'cityID', array(), array('id' => 'cityID'));
             
        }*/
        ?>
        
    </div>
    <div class="clear"></div>



    <div class="form_left">
        <?php echo $form->labelEx($model, 'address'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'address', array('size' => 60, 'maxlength' => 150, 'required' => 'required')); ?>

    </div>
    <?php echo $form->error($model, 'address'); ?>
    <div class="clear"></div>






    <div class="row buttons">
        <div class="form_left"></div>
        <div class="form_right">
            <?php echo CHtml::submitButton('Cập nhật'); ?>
        </div>
        <div class="clear"></div>
    </div>

    <?php $this->endWidget(); ?>
    <script type="text/javascript">
        function myformatter(date) {
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            var d = date.getDate();
            return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
        }
        function myparser(s) {
            if (!s)
                return new Date();
            var ss = (s.split('-'));
            var y = parseInt(ss[0], 10);
            var m = parseInt(ss[1], 10);
            var d = parseInt(ss[2], 10);
            if (!isNaN(y) && !isNaN(m) && !isNaN(d)) {
                return new Date(y, m - 1, d);
            } else {
                return new Date();
            }
        }
    </script>
</div><!-- form -->